package com.zx.notification.common.mapstruct;

import com.zx.notification.common.enums.ReadStatusEnum;
import com.zx.notification.common.model.InboxReadRecords;
import com.zx.notification.common.vo.InboxReadRecordsVO;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.ReportingPolicy;

/**
 * <p>
 * description: 站内信阅读记录映射器 <br>
 * create: 2025-10-16
 * </p>
 *
 * @author zhou  xun
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface InboxReadRecordsMapStructMapper {

    /**
     * 将InboxReadRecords实体转换为InboxReadRecordsVO视图对象
     *
     * @param inboxReadRecords 站内信阅读记录实体
     * @return InboxReadRecordsVO视图对象
     */
    InboxReadRecordsVO inboxReadRecordsToInboxReadRecordsVO(InboxReadRecords inboxReadRecords);

    /**
     * 在映射完成后，设置描述性字段
     *
     * @param inboxReadRecords   站内信阅读记录实体
     * @param inboxReadRecordsVO 站内信阅读记录VO
     */
    @AfterMapping
    default void setDescriptions(InboxReadRecords inboxReadRecords, @MappingTarget InboxReadRecordsVO inboxReadRecordsVO) {
        // 设置阅读状态描述
        ReadStatusEnum statusEnum = ReadStatusEnum.getEnumByCode(inboxReadRecords.getReadStatus());
        if (statusEnum != null) {
            inboxReadRecordsVO.setReadStatusDesc(statusEnum.getDesc());
        }
        // title和content字段将在查询时通过join操作从system_notifications表中获取
        // 这里不需要特别设置
    }
}